-
-
Notifications
You must be signed in to change notification settings - Fork 510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade eclib to version 20241112 #38962
base: develop
Are you sure you want to change the base?
Conversation
Anyone looking at this ticket now would assume that there is something wrong with it as several automatic checks have failed. But none of the failures have (as far as I can see) anything to do with the new eclib. I myself am not going to take any further action on this unless someone tells me that I am wrong about this. |
This requires patching sagelib due to API changes. See https://gitlab.archlinux.org/archlinux/packaging/packages/sagemath/-/blob/main/eclib-20241112.patch?ref_type=heads |
Thanks. I will make the changes you suggest in the link and update the PR. |
Documentation preview for this PR (built with commit 893e20e; changes) is ready! 🎉 |
28c0400
to
6967897
Compare
The forced push was just after rebasing on current develop. |
As usual I have no idea what is making any of the failures, this time I am more confident that it is nothing to do with this PR but whi knows? I hope someone does. |
Only had a quick look but at least the build failures for "Build & Test using Meson" are in the files changed in this PR. I suppose the problem is that these changes are not backwards compatible. Could you make compile sage with both the old and new version of eclib? If not, I'm afraid this PR has to wait until the new version is available on conda. |
Thanks for the explanation. I had thought, apparently wrongly, that the code in spkg-configure.m4 which checks for the existence of an installed eclib version which is new enough was there precisely to deal with this situation. If you are building Sage in an environment where only a too-old eclib is available, then the build process will build its own version of eclib. No? That certainly used to be the case. If not, then I don't see how any upstream developer (e.g. me for eclib) can ever reliably upgrade their library for Sage. |
If one uses conda, then all of sage-the-distro (everything under the Is it really not possible to support both the old and new version of ecm in sage? |
(eclib not ecm) I will try -- there are very few lines which had to be different in the wrapping code. |
OK, I can do away with the get_entries() methods which used to return a scalar* and now return a vector[scalar], and use the methods which deliver individual entries. Incidentally, I would be amazed if there was anyone in the world who actually use this part of eclib in Sage: it is the conversion to a Sage matric f an eclib matrix, as returned by the Hecke operator functions on a CremonaModularSymbols space. I will update the interface code and update this PR. |
6967897
to
f0dc04f
Compare
OK, I rebased on current develop and made a few changes to the interface so that neither scalar* nor vector[scalar] are used. I hope this is enough. |
I checked the logs for failing tests and the only one is in src/sage/libs/gap/element.pyx which is not relevant to this PR, I think. In particular, it was happy with the tests in src/sage/libs/eclib. |
still needs a rebase |
48bbf7e
to
8754c70
Compare
If someone tells me what is now wrong and how to fix it, and if it is anything to do with my latest attempt to upgrade eclib (which used to be easy enough for me to do) then I will fix it. |
lgtm |
<!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> Fixed sagemath#38960 ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x ] The description explains in detail what this PR is about. - [ x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#38962 Reported by: John Cremona Reviewer(s): Dima Pasechnik
Segfaults on 32-bit:
|
See: JohnCremona/eclib#81 (comment) A new version of Edit: I copy here the patch, since the url above is gone. --- a/libsrc/arith.cc
+++ b/libsrc/arith.cc
@@ -429,8 +430,8 @@ int new_modrat(long n, long m, long& a, long& b);
int modrat(long n, long m, long& a, long& b)
{
- // return old_modrat(n, m, a, b);
- return new_modrat(n, m, a, b);
+ return old_modrat(n, m, a, b);
+ //return new_modrat(n, m, a, b);
}
int old_modrat(long n, long m, long& a, long& b) |
@tornaria How about using one of the methods given in https://stackoverflow.com/questions/1505582/determining-32-vs-64-bit-in-c to choose which method to use? In fact it might be worth setting a macro in one place (such as interface.h) which can then be checked elsewhere. There's an issue about whether this should be done at compile time or run time. Since the function modrat() is used a lot it would be best to decide at compile time, and that appears to rely on having the right headers to define the correct macros. |
Are you sure this is an issue about 32-bit vs. 64-bit, or is this a bug that is just easier to trigger on 32-bit? |
Well, I am certain that it is possible to trigger crashes on 64-bit machines -- I do not check that whenever I multiply two long ints that the product fits into a long int! I have a plan to replace all my integer arithmetic with FLINT integers, but that will take a long time and be very tedious. At the same time I would use FLINT for all floating point. I don't see an easy way of doing this incrementally, so I am not very enthusiastic about starting! |
Sure, if you are going to replace arithmetic, it may not be worth fixing modrat now. Note that flint has rational reconstruction, it even special cases the 1 limb case https://github.com/flintlib/flint/blob/main/src/fmpq/reconstruct_fmpz_2.c#L258 The trick there is doing the gaussian reduction on the first row instead of the norm. This avoids the arithmetic on integers of double the size. Of course, you can't go all the way of the gcd or you would obtain a rational number of the form |
IMHO rather than moving between concrete implementations of integers, one should have templated code which allows plugging in whatever available integers (or, horror, algebraic numbers?) |
Good point -- in fact eclib does this for its vector, matrix and sparse matrix classes. Not using proper C++ templates though, as I wrote this before they were standard. I have no plans to implement algebraic numbers in eclib! Better would be to gradually transfer more of eclib to FLINT (e.g. all the elliptic curve classes, methods and functions. |
templates were already standard 25 years ago, e.g. CGAL was using them back then already. Another question is how hard they were to use :-) But now C++ is basically a different language, and templates are easier to use. |
I am going to replace eclib version 20241112 with a new version with three extra tiny commits, and I hope that will deal with the hold-up here. (1) as @tornaria suggested JohnCremona/eclib#81, revert to the older version of modrat to avoind the 32-bit test failure; (2) as reported by @thierry-FreeBSD JohnCremona/eclib#83 (3) ding an #include to keep FLINT happy. |
Fixed #38960
📝 Checklist
⌛ Dependencies